<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span {
            width: 50px;
            height: 50px;
            display: inline-block;
            text-align: center;
            line-height: 50px;
            border: 1px solid black;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <p>vue你好,情人节快乐,</p>
    <p>不好</p>
    <div id="app">
        <p>{{text}}</p>
        <span @click="sub">-</span><span>{{num}}</span><span v-on:click="add">+</span>

    </div>
</body>
<script src="../vue.js"></script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            text: "你好，vue",
            num: 0,
        },
        methods: {
            add: function() {
                if (this.num < 10) {
                    this.num++;

                } else {
                    alert("不能再加了哦")
                }
            },
            sub: function() {
                if (this.num > 0) {
                    this.num--;
                } else {
                    alert("不能再减了哦")
                }
            }
        }

    })
</script>

</html>